<?php

namespace DP\Builder\Core;

use DP\Builder\Core\Interfaces\ItemInterface;

class Meal
{
    private $items = [];

    public function addItem(ItemInterface $item)
    {
        $this->items[] = $item;
    }

    public function getCoast()
    {
        $items = $this->items;
        $coast = 0;

        foreach ($items as $v) {
            $coast += $v->price();
        }

        return $coast;
    }
    
    public function showItems()
    {
        foreach ($this->items as $item) {
            echo 'name:' . $item->name() . PHP_EOL;
            echo 'Packing:' . $item->packing()->pack() . PHP_EOL;
            echo 'price:' . $item->price() . PHP_EOL;
            echo '<br>';
        }
    }
}
